<?php 
	echo $this->element('user');
?>	
	<script type="text/javascript">
		function changeSheet(form)
		{
			var index = form.assessment.selectedIndex;
			var value = form.assessment.options[index].value;
			location = "/assessments/cheat_sheet/" + value;
		};
	</script>
<div class="aTitle">
	<h2>Update User Details</h2>
</div>
<div class="assessment">
	<div id="aSheet">

	<form name='change'>
<?php
echo "<select name='assessment' onChange='changeSheet(this.form)'>";
foreach ($assessment_list as $assess)
{
	$assessment_id = $assess['Assessment']['id'];
	$assessment_name = $assess['Assessment']['name'];
	if($assessment_id == $ass_id)
		echo "<option selected value='".$assessment_id."'>".$assessment_name."</option>";
	else
		echo "<option value='".$assessment_id."'>".$assessment_name."</option>";
}
echo "</select>";
echo "</form>";
$count = 1;


	$results = '<div id="tabs_'.$assessment['Assessment']['id'].'"><h1>'.$assessment['Assessment']['name'].'</h1>';

	$total_marks = 0;

	foreach ($assessment['Questiongroup'] as $questiongroup)
	{
		$results .= '<h2>'.$questiongroup['name'].'&nbsp;-&nbsp;'.$questiongroup['description'].'</h2>';
		
		foreach ($questiongroup['Question'] as $question)
		{
			$results .= '
			<h3>'.$question['rank'].'.&nbsp;'.$question['name'].'&nbsp;-&nbsp;'.$question['question'].'</h3>
			<ul class="answer_list">';

			foreach ($question['Answer'] as $answer)
			{
				$print_answer = '';

				if ($question['Answervalue']['variable_type'] == 'text')
				{
					$print_answer = $answer['answer_text'] . " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " . $answer['return_value'];
				}
				elseif ($question['Answervalue']['variable_type'] == 'decimal')
				{
					$print_answer = $answer['answer_decimal'].'&nbsp;'.$question['Answervalue']['abbreviation'];
				}
				elseif ($question['Answervalue']['variable_type'] == 'int')
				{
					$print_answer = $answer['answer_int'].'&nbsp;'.$question['Answervalue']['abbreviation'];
				}
				elseif ($question['Answervalue']['variable_type'] == 'file')
				{

					if ($answer['correct'] == 1)
					{
						$answer_is_correct = 'Correct';
					}
					else
					{
						$answer_is_correct = 'Incorrect';
					}
					$print_answer = '<img src="'.$answer['answer_text'].'"><br />'.@$answer_is_correct;

				}

				$answer_class = 'answer_incorrect';
				
				if ($answer['correct'] == 1)
				{
					$answer_class = 'answer_correct';
				}

				$results .= '<li><span class="'.$answer_class.'">'.$print_answer.'</span></li>';
			}
		}
	}

	$results .= '</ul></div>';

	print $results;

?>
</div>
</div>